package cf.huzpsb.bcgod;

import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;

import java.util.Iterator;

public class ListCMD extends Command {
    public ListCMD(String name, String permission, String... aliases) {
        super(name, permission, aliases);
    }

    public void execute(CommandSender sender, String[] args) {
        if (!(sender instanceof ProxiedPlayer)) {
            sender.sendMessage("§c后台不能使用此命令!");
        } else if (((ProxiedPlayer) sender).getServer().getInfo().getName().equalsIgnoreCase(Main.login)) {
            sender.sendMessage("§c登录区域禁止使用!");
        } else {
            ProxiedPlayer player = (ProxiedPlayer) sender;
            StringBuilder sb = new StringBuilder();
            Iterator var17 = Main.getInstance().getProxy().getPlayers().iterator();
            while (var17.hasNext()) {
                ProxiedPlayer player1 = (ProxiedPlayer) var17.next();
                sb.append(player1.getName());
                sb.append(", ");
            }
            player.sendMessage(sb.toString());
        }
    }
}
